import request from '@/config/axios'
import type { PageParam } from '@/types/global'

/**
 * 商品品牌
 */
export interface BrandVO {
  /**
   * 品牌编号
   */
  id?: number
  /**
   * 品牌名称
   */
  name: string
  /**
   * 品牌图片
   */
  picUrl: string
  /**
   * 品牌排序
   */
  sort?: number
  /**
   * 品牌描述
   */
  description?: string
  /**
   * 开启状态
   */
  status: number
}

// 查询品牌列表
export const getBrandPage = (params: PageParam) => {
  const finalParams = { ...params, productType: 'SHOP' }
  return request.get({
    url: '/product/brand/page',
    params: finalParams
  })
}

// 查询品牌详情
export const getBrand = (id: number) => {
  const url = `/product/brand/get?id=${id}&productType=SHOP`
  return request.get({ url })
}

// 新增品牌
export const createBrand = (data: BrandVO) => {
  const finalData = { ...data, productType: 'SHOP' }
  return request.post({
    url: '/product/brand/create',
    data: finalData
  })
}

// 修改品牌
export const updateBrand = (data: BrandVO) => {
  const finalData = { ...data, productType: 'SHOP' }
  return request.put({
    url: '/product/brand/update',
    data: finalData
  })
}

// 删除品牌
export const deleteBrand = (id: number) => {
  const url = `/product/brand/delete?id=${id}&productType=SHOP`
  return request.delete({ url })
}

// 获取商品分类精简信息列表
export const getSimpleBrandList = () => {
  const url = '/product/brand/list-all-simple?productType=SHOP'
  return request.get({ url })
}
